from selenium import webdriver
import time
# 对浏览器的操作
driver = webdriver.Firefox()
driver.get("https://www.baidu.com/")
time.sleep(3)
# 浏览器最大化
driver.maximize_window()
driver.find_element_by_id("kw").send_keys("知否")
driver.find_element_by_id("su").click()
time.sleep(4)
# 设置浏览器的宽和高
driver.set_window_size(400,1000)
time.sleep(3)
# driver.maximize_window()
# time.sleep(3)

# # 浏览器后退
# driver.back()
# time.sleep(5)
# # 浏览器前进
# driver.forward()
# time.sleep(5)

# 浏览器滚动条的控制
# 底端
js0 = "var q=document.documentElement.scrollTop=10000"
driver.execute_script(js0)
time.sleep(3)
# 顶端
js1 = "var q=document.documentElement.scrollTop=0"
driver.execute_script(js1)


time.sleep(3)
driver.quit()